<?php
// +----------------------------------------------------------------------
// | 供应链
// +----------------------------------------------------------------------
namespace app\schain\validate;

use think\Validate;

class AdminEnterpriseValidate extends Validate {
	protected $rule = [
		// 'categories' => 'require',
		'ent_title' => 'require',
		'ent_email' => 'checkEmail',
	];
	protected $message = [
		// 'categories.require' => '请指定企业分类！',
		'ent_title.require' => '企业标题不能为空！',
		'ent_email.checkEmail' => '邮箱格式不正确!',
	];

	protected $scene = [
		'add' => ['ent_title,ent_email'],
		// 'edit' => ['user_login,user_email'],
	];

	// 验证 email 格式
	protected function checkEmail($value, $rule, $data) {
		if (filter_var($value, FILTER_VALIDATE_EMAIL)) {
			return true;
		}
		return '邮箱格式不正确!';
	}

}